/**
 * 我的手牌单张
 */
class MyHandCard extends eui.Component {
	public beenTouched = false;
	public value: number;
	public card: how.CardGroup;
	public bg: eui.Image;
	public isUseDarw = true;
	public constructor() {
		super();
		this.skinName = "MyHandCardSkin";
	}

	public childrenCreated(): void {
		if (this.isUseDarw) {
			this.card.addEventListener(how.CardGroup.PUT, this.onPut, this);
		}
		this.visible = false;
	}
	/**
 	* 设置数据
 	*/
	public setData(value: number): void {
		this.visible = true;
		if (value > 0) {
			this.value = value;
			this.card.source = "mj_card_" + value + "_png";
			this.card.hight = true;
		} else {
			this.bg.source = "mj_mhback_png";
			this.bg.visible = true;
			this.card.source = "";
		}
	}

	/**
	 * 单击上升
	 */
	public onTouch(): void {
		let gs:MJGameSceneView = <MJGameSceneView>D.App.gameView;
		if (this.beenTouched) {
			gs.userOutCard(this.value);
			this.beenTouched = false;
			return;
		}
		if (egret.is(this.parent, "MyHand")) {
			(this.parent as MyHand).allCardDown();
		} else {
			(this.parent.parent as MyHand).allCardDown();
		}
		this.bottom = 30;
		this.beenTouched = true;
	}
	private onPut(): void {
		let gs:MJGameSceneView = <MJGameSceneView>D.App.gameView;
		gs.userOutCard(this.value);
	}
}